package Controller_Servlet;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import Model_Db.DbUtil;
@WebServlet("/update")
public class update extends HttpServlet {
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
	    request.setCharacterEncoding("UTF-8");  
	    String user=request.getParameter("username");
	    String Pwd=request.getParameter("password");
	    String sql="update t_patient set Pwd='"+Pwd+"'"+"where ID='"+user+"'"+" or Tel_Number='"+user+"'";
	    DbUtil run=new DbUtil();
	    int n=run.updateSQL(sql);
	    if(n>=1)
	        request.getRequestDispatcher("登入窗口.jsp").forward(request,response);
		else 
		   request.getRequestDispatcher("注册窗口.jsp").forward(request,response);
	}
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doGet(request, response);
	}
}